package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CwLsparking;
import com.ruoyi.system.service.ICwLsparkingService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 临时车位费Controller
 * 
 * @author ruoyi
 * @date 2022-11-29
 */
@RestController
@RequestMapping("/system/lsparking")
public class CwLsparkingController extends BaseController
{
    @Autowired
    private ICwLsparkingService cwLsparkingService;

    /**
     * 查询临时车位费列表
     */
    @PreAuthorize("@ss.hasPermi('system:lsparking:list')")
    @GetMapping("/list")
    public TableDataInfo list(CwLsparking cwLsparking)
    {
        startPage();
        List<CwLsparking> list = cwLsparkingService.selectCwLsparkingList(cwLsparking);
        return getDataTable(list);
    }

    /**
     * 导出临时车位费列表
     */
    @PreAuthorize("@ss.hasPermi('system:lsparking:export')")
    @Log(title = "临时车位费", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CwLsparking cwLsparking)
    {
        List<CwLsparking> list = cwLsparkingService.selectCwLsparkingList(cwLsparking);
        ExcelUtil<CwLsparking> util = new ExcelUtil<CwLsparking>(CwLsparking.class);
        util.exportExcel(response, list, "临时车位费数据");
    }

    /**
     * 获取临时车位费详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:lsparking:query')")
    @GetMapping(value = "/{lid}")
    public AjaxResult getInfo(@PathVariable("lid") Long lid)
    {
        return success(cwLsparkingService.selectCwLsparkingByLid(lid));
    }

    /**
     * 新增临时车位费
     */
    @PreAuthorize("@ss.hasPermi('system:lsparking:add')")
    @Log(title = "临时车位费", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CwLsparking cwLsparking)
    {
        return toAjax(cwLsparkingService.insertCwLsparking(cwLsparking));
    }

    /**
     * 修改临时车位费
     */
    @PreAuthorize("@ss.hasPermi('system:lsparking:edit')")
    @Log(title = "临时车位费", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CwLsparking cwLsparking)
    {
        return toAjax(cwLsparkingService.updateCwLsparking(cwLsparking));
    }

    /**
     * 删除临时车位费
     */
    @PreAuthorize("@ss.hasPermi('system:lsparking:remove')")
    @Log(title = "临时车位费", businessType = BusinessType.DELETE)
	@DeleteMapping("/{lids}")
    public AjaxResult remove(@PathVariable Long[] lids)
    {
        return toAjax(cwLsparkingService.deleteCwLsparkingByLids(lids));
    }
}
